const http = require('http')
const server = http.createServer()
const PORT = 1234
//为request事件绑定处理函数
//也可以使用server.addListener
server.on('request', (req, res) => {
  res.writeHead(200, {'Content-Type': 'text/plain'})
  res.write('some words')
  console.log('success responed')
  res.end()
})

server.listen(PORT, 'localhost')
console.log(`Server running at http://localhost:${PORT}`)